<template>
  <div class="details_member">
    <el-table border :data="tableData">
      <el-table-column label="会员名称" prop="nickname" align="center"></el-table-column>
      <el-table-column label="卡类型" align="center">
        <template slot-scope="scope">
          {{ scope.row.cardType | typeFilter}}
        </template>
      </el-table-column>
      <el-table-column label="车牌号码" prop="carNum" align="center"></el-table-column>
      <el-table-column label="手机号码" prop="mobilePhone" align="center"></el-table-column>
      <el-table-column label="开始时间" prop="beginTime" align="center"></el-table-column>
      <el-table-column label="到期时间" prop="expireTime" align="center"></el-table-column>
      <el-table-column label="剩余天数" prop="surplusDay" align="center"></el-table-column>
      <el-table-column label="已停天数" prop="useDay" align="center"></el-table-column>
    </el-table>

    <el-pagination
      :hide-on-single-page="false"
      :current-page="searchForm.pageNum"
      :page-sizes="[5, 10, 15, 20]"
      :page-size="searchForm.pageSize"
      background
      style="margin-top:10px;"
      layout="total, sizes, prev, pager, next, jumper"
      :total="total"
      align="center"
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
    />

  </div>
</template>

<script>
  export default {
    props: ['row'],
    filters: {
      typeFilter(type) {
        switch(type) {
          case 1:
            return '月租卡';
          case 2:
            return '定制卡';
          case 100:
            return '白天卡';
          case 110:
            return '夜间卡'
        }
      }
    },
    data() {
      return {
        searchForm: {
          pageNum: 1,
          pageSize: 5
        },
        tableData: [],
        total: 0
      }
    },
    mounted() {
      this.searchForm.parkId = this.row.id;
      this.getAllCardRecordByParkId();
    },
    methods: {
      getAllCardRecordByParkId() {
        this.$axios({
          method: 'get',
          url: '/customer/card-record/getAllCardRecordByParkId',
          params: this.searchForm
        }).then((res) => {
          if(res.code == 200) {
            res.data.records.forEach(item => {
              item.expireTime = item.expireTime.slice(0,10);
              item.beginTime = item.beginTime.slice(0,10);
            })
            this.tableData = res.data.records;
            this.total = res.data.total;
          }
        })
      },

      // 分页修改每页显示条数
      handleSizeChange(val) {
        this.searchForm.pageSize = val;
        this.getAllCardRecordByParkId();
      },
      // 分页跳转页面
      handleCurrentChange(val) {
        this.searchForm.pageNum = val;
        this.getAllCardRecordByParkId();
      }
    }
  }
</script>

<style scoped>







</style>
